package com.leetcode.链表;

//反转链表
public class lc_206 {
    public static void main(String[] args) {

    }

    public static ListNode reverseList(ListNode head){
        //思路: 插入虚拟头节点,使用尾插法进行插入反转
        ListNode dumHead = new ListNode();
        ListNode curNode = head;

        while(curNode != null){
            ListNode nextNode = curNode.next;
            curNode.next = dumHead.next;
            dumHead.next = curNode;
            curNode = nextNode;
        }
        return dumHead.next;
    }
}
